/*
 * @Author: shenya
 * @Date: 2023-09-07 15:56:00
 * @Description: 话题管理option
 */
export const tableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    viewBtn: false,
    delBtn: false,
    span: 24,
    column: [
      {
        label: '话题编号',
        prop: 'id',
        width: 80,
      },
      {
        label: '话题名称',
        prop: 'name',
        search: true,
        width: 160,
        overHidden: true,
      },
      {
        label: '参与数',
        prop: 'joinQty',
        width: 100,
      },
      {
        label: '创建者',
        prop: 'createByName',
        width: 160,
        overHidden: true,
      },
      {
        label: '加Hot',
        prop: 'hotFlag',
        type: 'switch',
        search: true,
        slot: true,
        dicData: [
          {
            label: 'yes',
            value: '1',
          },
          {
            label: 'no',
            value: '0',
          },
        ],
      },
      {
        label: '是否推荐',
        prop: 'recommendFlag',
        type: 'switch',
        search: true,
        slot: true,
        dicData: [
          {
            label: '已推荐',
            value: '1',
          },
          {
            label: '未推荐',
            value: '0',
          },
        ],
      },
      {
        label: '是否屏蔽',
        prop: 'shieldFlag',
        search: true,
        type: 'switch',
        slot: true,
        dicData: [
          {
            label: '已屏蔽',
            value: '1',
          },
          {
            label: '未屏蔽',
            value: '0',
          },
        ],
      },
      {
        label: '创建时间',
        prop: 'createTime',
        width: 160,
        search: true,
        type: 'datetime',
        searchRange: true,
        format: 'yyyy-MM-dd HH:mm:ss',
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
      },
    ],
  };
};
//分类option
export const formOption = (isView) => {
  return {
    labelWidth: 100,
    submitBtn: !isView,
    emptyBtn: false,
    cancelBtn: true,
    column: [
      {
        label: '话题分类',
        prop: 'name',
        maxlength: 5,
        showWordLimit: true,
        span: 24,
        row: true,
        rules: [
          {
            required: true,
            message: '请输入话题分类',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '排序',
        prop: 'sort',
        type: 'number',
        controlsPosition: 'left',
        min: 1,
        max: 999999,
        span: 12,
        row: true,
        value: '1',
        rules: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur',
          },
          {
            pattern: /^[0-9]*[1-9][0-9]*$/,
            message: '排序只能输入正整数',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '分类描述',
        prop: 'content',
        type: 'textarea',
        span: 24,
        row: true,
        maxlength: 200,
        showWordLimit: true,
      },
      {
        label: '是否隐藏',
        prop: 'hideFlag',
        type: 'switch',
        display: isView,
        dicData: [
          {
            label: '否',
            value: '0',
          },
          {
            label: '是',
            value: '1',
          },
        ],
        tip: '设置分类隐藏，移动端话题分类列表不可见该话题分类，但仍可搜索到下面的话题',
      },
    ],
  };
};
//话题option
export const topicOption = (isView) => {
  return {
    submitBtn: false,
    emptyBtn: false,
    column: [
      {
        label: '话题分类',
        prop: 'classifyId',
        formslot: true,
        // dicUrl: '/core/topic/classify/list',
        // dicFlag: true,
        // props: {
        //   label: 'name',
        //   value: 'id',
        // },
        span: 24,
        row: true,
        type: 'select',
        rules: [
          {
            required: true,
            message: '请输入话题分类',
            trigger: 'change',
          },
        ],
      },
      {
        label: '话题名称',
        prop: 'name',
        maxlength: 30,
        showWordLimit: true,
        disabled: !isView,
        span: 24,
        row: true,
        rules: [
          {
            required: true,
            message: '请输入话题名称',
            trigger: 'blur',
          },
          {
            pattern: /^((?!#).)*$/,
            message: '话题名称不能输入#',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '排序',
        prop: 'sort',
        type: 'number',
        controlsPosition: 'left',
        min: 1,
        max: 999999,
        span: 12,
        row: true,
        value: '1',
        rules: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur',
          },
          {
            pattern: /^[0-9]*[1-9][0-9]*$/,
            message: '排序只能输入正整数',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '话题图标',
        prop: 'pic',
        span: 24,
        limit: 1,
        row: true,
        type: 'upload',
        fileSize: 10 * 1024,
        fileType: 'img',
        listType: 'picture-img',
        accept: '.jpg,.png',
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        oss: 'qiniu',
        rules: [
          {
            required: true,
            message: '请选择话题图标',
            trigger: 'change',
          },
        ],
      },
      {
        label: '话题简介',
        prop: 'content',
        type: 'textarea',
        span: 24,
        row: true,
        maxlength: 2000,
        showWordLimit: true,
        rules: [
          {
            required: true,
            message: '请输入话题简介',
            trigger: 'blur',
          },
        ],
      },
    ],
  };
};
